package co.yixiang.modules.member.entity.domain;

import co.yixiang.common.domain.BaseDomain;
import co.yixiang.common.validation.Phone;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;

@Data
@TableName("yx_user_address")
public class UserAddress extends BaseDomain {
    /** 地址id */
    @TableId
    private Long id;
    /** 用户uid */
    private String uid;
    /** 收获人姓名 */
    @NotEmpty(message = "收货人姓名不能为空")
    private String realName;
    /** 收货人电话 */
    @Phone
    private String phone;
    /** 省份 */
    @NotBlank(message = "地址不能为空")
    private String province;
    /** 市 */
    @NotBlank(message = "地址不能为空")
    private String city;
    /** 市id */
    private Integer cityId;
    /** 区 */
    @NotBlank(message = "地址不能为空")
    private String district;
    /** 详细地址 */
    @NotEmpty(message = "详细地址不能为空")
    private String detail;
    /** 邮编 */
    private String postCode;
    /** 经度 */
    private String longitude;
    /** 纬度 */
    private String latitude;
    /** 是否默认 */
    private Integer isDefault = 0;

    @TableField(exist = false)
    private String consigneeAddressPath;
    @TableField(exist = false)
    private String consigneeAddressIdPath;

    public String getConsigneeAddressPath() {

        return this.province+"/"+ this.city +"/" +this.district + " " + this.detail;
    }
    public String getConsigneeAddressIdPath() {
        return this.longitude+","+ this.latitude;
    }


}
